package com.example.aboutwork.enumhandle;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.lang.NonNull;

import java.util.Arrays;

@Getter
@AllArgsConstructor
public enum WorkTimeType {
    DAY(1,"白班"),
    NIGHT(2,"夜班"),
    MIDDLE(3,"中班");

    @EnumValue
    private final Integer value;
    @JsonValue
    private final  String desc;


    public static WorkTimeType getByValue(@NonNull Integer value){
        return Arrays.stream(WorkTimeType.values()).filter(a -> a.getValue().equals(value)).findFirst()
                .orElseThrow(() -> new RuntimeException("workTime 的类型错误"));
    }

}
